var mysql      = require('mysql');

var pool = mysql.createPool({
	connectionLimit : 10,
	host			:"localhost",
	user 			:"root",
	password		:"123456",
	database		:"test"
});

pool.getConnection(function(err,conn){
  if(err){
    console.log(err);
    return;
  }

  conn.beginTransaction(function(err){
  	if(err){
  		console.log(err);
  		return;
  	}

  	conn.query("insert into user_info set name=?",
  		["name_5"],
  		function(err,insertRet){
  			if(err){
  				return conn.rollback();
  			}

  			conn.commit(function(err){
  				if(err){
  					return conn.rollback();
  				}
  			});

  			console.log("success");
  	});
  });
});